﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.HVAC.LevelIndependentTag;
using YArchitech.LIB;
using YArchitech.Revit;

namespace YArchitech.HVAC.DuctTerminalTag
{
	public class DuctTerminalTagOperate
	{
		public DuctTerminalTagOperate(Autodesk.Revit.DB.Document doc, FrmDuctTerminalTag frm)
		{
			this.doc = doc;
			this.frm = frm;
		}

		public void Execute()
		{
			this.LoadSetFamily();
			for (;;)
			{
				try
				{
					this.TagDuctTerminal();
					this.CreateTagGroup();
					this.doc.Regenerate();
					continue;
				}
				catch (Autodesk.Revit.Exceptions.OperationCanceledException ex)
				{
					ex.ToString();
					if (!this.frm.contorProcess)
					{
						continue;
					}
				}
				catch (Exception ex2)
				{
					ex2.ToString();
					continue;
				}
				finally
				{
					if (this.transaction != null && ((int)this.transaction.GetStatus() == 1 || (int)this.transaction.GetStatus() == 5))
					{
						this.transaction.RollBack();
					}
					this.newgrpElements.Clear();
				}
				break;
			}
		}

		private void SetTagAlignStyle()
		{
			if (this.singleLine == null || this.independentTags == null || this.independentTags.Count < 1)
			{
				return;
			}
			MarkOperation markOperation = new MarkOperation();
			foreach (IndependentTag tag in this.independentTags)
			{
				markOperation.SetAlignStyle(tag, this.singleLine, this.tagLocation, "风口");
			}
		}

		private void CreateTagGroup()
		{
			this.transaction = new Transaction(this.doc, "创建标注详图线组");
			this.transaction.Start();
			this.CerateTagLinesGroup();
			this.transaction.Commit();
		}

		private void TagDuctTerminal()
		{
			this.transaction = new Transaction(this.doc, "风口标注");
			this.transaction.Start();
			this.GetTagElems();
			this.SelectTagElem();
			this.GetTagLocation();
			this.LayTagFamily();
			this.CreateTagLines();
			this.SetTagAlignStyle();
			this.transaction.Commit();
		}

		private void LoadSetFamily()
		{
			this.transaction = new Transaction(this.doc, "加载设置族");
			this.transaction.Start();
			this.LoadFamily();
			this.transaction.Commit();
			this.SetFamilyParams();
		}

		private void GetTagElems()
		{
			this.frm.contorProcess = true;
			this.uiDoc = new UIDocument(this.doc);
			for (;;)
			{
				if (this.uiDoc.Selection.GetElementIds().Count > 0)
				{
					this.elems = this.GetPreSelectedElems(this.uiDoc.Selection.GetElementIds().ToList<ElementId>());
				}
				else
				{
					this.elems = this.uiDoc.Selection.PickElementsByRectangle(new DuctTerminalFilter(), "请框选需要标注的风口...").ToList<Element>();
				}
				if (this.elems.Count != 0)
				{
					if (this.CompareElemsParams())
					{
						break;
					}
					YJKMessageBox.Show("框选范围内的风口名称、尺寸大小、风量需一致...");
				}
			}
		}

		private bool CompareElemsParams()
		{
			return true;
		}

		private bool CompareElemsName()
		{
			string a = this.elems.ElementAt(0).GetParameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString();
			foreach (Element element in this.elems)
			{
				if (a != element.GetParameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString())
				{
					return false;
				}
			}
			return true;
		}

		private bool CompareElemsSize()
		{
			string text = this.elems.ElementAt(0).GetParameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString();
			if (text.Contains("方形"))
			{
				string a = this.elems.ElementAt(0).GetParameter("喉口宽度").AsValueString() + "×" + this.elems.ElementAt(0).GetParameter("喉口高度").AsValueString();
				foreach (Element element in this.elems)
				{
					if (a != element.GetParameter("喉口宽度").AsValueString() + "×" + element.GetParameter("喉口高度").AsValueString())
					{
						return false;
					}
				}
			}
			if (text.Contains("圆形"))
			{
				string a2 = this.elems.ElementAt(0).GetParameter("喉口直径").AsValueString();
				foreach (Element element2 in this.elems)
				{
					if (a2 != element2.GetParameter("喉口直径").AsValueString())
					{
						return false;
					}
				}
			}
			return true;
		}

		private bool CompareElemsAirFlow()
		{
			string a = this.elems.ElementAt(0).GetParameter("风量").AsValueString();
			foreach (Element element in this.elems)
			{
				if (a != element.GetParameter("风量").AsValueString())
				{
					return false;
				}
			}
			return true;
		}

		private void SelectTagElem()
		{
			Reference reference = this.uiDoc.Selection.PickObject((Autodesk.Revit.UI.Selection.ObjectType)1, new ElemInElementsFilter(this.elems), "请点选标注对象...");
			this.elem = this.doc.GetElement(reference.ElementId);
			this.SetTagParams();
		}

		private void GetTagLocation()
		{
			bool drawLineBox = this.frm.markSetting.DrawLineBox == "true";
			using (DuctTerminalTagLinesJin ductTerminalTagLinesJin = new DuctTerminalTagLinesJin(this.uiDoc, 0.0, drawLineBox))
			{
				this.SetTagLinesLength();
				ductTerminalTagLinesJin.tagContentChecked = (this.frm.chkName.Checked || this.frm.chkAirAmount.Checked);
				ductTerminalTagLinesJin.StartPoint = (this.elem.Location as LocationPoint).Point;
				this.uiDoc.Selection.PickPoint("请点选需要标注的位置....");
				this.tagLocation = ductTerminalTagLinesJin.TagLocation;
				this.tagDirectionVector = ductTerminalTagLinesJin.directionVector;
				this.verticalLineLength = ductTerminalTagLinesJin.verticalLineLength * 304.8;
				this.tagLines = ductTerminalTagLinesJin.resultLines;
				this.singleLine = this.GetSingleBaseLine(this.tagLines);
				ductTerminalTagLinesJin.Dispose();
			}
		}

		private YJKLine GetSingleBaseLine(List<Line> listLine)
		{
			YJKLine result = null;
			int num = 0;
			XYZ xyz = new XYZ(1.0, 0.0, 0.0);
			foreach (Line curve in listLine)
			{
				YJKLine hyline = new YJKLine(curve.GetEndPoint(0), curve.GetEndPoint(1));
				XYZ lineVector = hyline.LineVector;
				if (lineVector.IsAlmostEqualTo(xyz, 0.0001) || lineVector.IsAlmostEqualTo(-1.0 * xyz, 0.0001))
				{
					result = hyline;
					num++;
				}
			}
			if (num != 1)
			{
				result = null;
			}
			return result;
		}

		private void LayTagFamily()
		{
			this.CreateIndependentTags();
		}

		private void CreateTagLines()
		{
			for (int i = 0; i < this.tagLines.Count; i++)
			{
				DetailCurve detailCurve = this.doc.CreatYJKDetailCurve(this.tagLines.ElementAt(i));
				this.newgrpElements.Insert(detailCurve);
				int num = 0;
				while (i < RevitVersionFuncs.LineStyles(this.doc, detailCurve).Size)
				{
					GraphicsStyle graphicsStyle = RevitVersionFuncs.LineStyles(this.doc, detailCurve).get_Item(num) as GraphicsStyle;
					int hashCode = -2000042.GetHashCode();
					if (graphicsStyle.GraphicsStyleCategory.GetHashCode() == hashCode)
					{
						detailCurve.LineStyle = graphicsStyle;
						break;
					}
					num++;
				}
			}
		}

		public void CerateTagLinesGroup()
		{
			if (this.newgrpElements.Size < 1)
			{
				return;
			}
			AssociationMarkInfo.WriteMarkInfoToElement(RevitVersionFuncs.NewGroup(this.doc, this.newgrpElements), MarkType.DuctTerminal);
		}

		private double GetMovingDistance()
		{
			string text = this.elems.ElementAt(0).GetParameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString();
			double result = 0.0;
			double result2 = 0.0;
			if (text.Contains("圆形") && this.elem.GetParameter("风口直径") != null)
			{
				result = this.elem.GetParameter("风口直径").AsDouble() / 2.0;
			}
			else if (text.Contains("圆形") && this.elem.GetParameter("风管直径") != null)
			{
				result = this.elem.GetParameter("风管直径").AsDouble() / 2.0;
			}
			else
			{
				foreach (object obj in (this.elems.ElementAt(0) as FamilyInstance).Symbol.Parameters)
				{
					Parameter parameter = (Parameter)obj;
					if (parameter.Definition.Name == "风管直径")
					{
						result = Convert.ToDouble(parameter.AsValueString()) / 2.0;
						break;
					}
				}
			}
			if (!text.Contains("圆形") && this.elem.GetParameter("风口宽度") != null)
			{
				result2 = this.elem.GetParameter("风口宽度").AsDouble() / 2.0;
			}
			if (!text.Contains("圆形") && this.elem.GetParameter("风管宽度") != null)
			{
				result2 = this.elem.GetParameter("风管宽度").AsDouble() / 2.0;
			}
			else
			{
				foreach (object obj2 in (this.elems.ElementAt(0) as FamilyInstance).Symbol.Parameters)
				{
					Parameter parameter2 = (Parameter)obj2;
					if (parameter2.Definition.Name == "风管宽度")
					{
						result = Convert.ToDouble(parameter2.AsValueString()) / 2.0;
						break;
					}
				}
			}
			if (!text.Contains("圆形"))
			{
				return result2;
			}
			return result;
		}

		private void CreateIndependentTags()
		{
			if (this.frm.markSetting.DrawLineBox == "true")
			{
				this.LineBoxCreateTags();
				return;
			}
			this.CreateTags();
		}

		private void LineBoxCreateTags()
		{
			int i = 0;
			int i2 = 1;
			int i3 = 2;
			int i4 = 3;
			if (!this.frm.chkName.Checked && !this.frm.chkAirAmount.Checked)
			{
				i2 = 2;
				i3 = 1;
			}
			if (this.tagDirectionVector.VerticalVector.AngleTo(this.doc.ActiveView.UpDirection) > Math.PI*.5)
			{
				if (!this.frm.chkName.Checked && !this.frm.chkAirAmount.Checked)
				{
					i2 = 1;
					i3 = 2;
				}
				else
				{
					i = 1;
					i2 = 0;
					i3 = 3;
					i4 = 2;
				}
			}
			this.independentTags.Clear();
			if (this.tagDirectionVector.HorizontalVector.AngleTo(this.doc.ActiveView.RightDirection) > Math.PI*.5)
			{
				if (!this.frm.chkName.Checked && !this.frm.chkAirAmount.Checked)
				{
					i2 = 2;
					i3 = 1;
					if (this.tagDirectionVector.VerticalVector.AngleTo(this.doc.ActiveView.UpDirection) > Math.PI*.5)
					{
						i2 = 1;
						i3 = 2;
					}
				}
				else
				{
					i = 2;
					i2 = 3;
					i3 = 0;
					i4 = 1;
					if (this.tagDirectionVector.VerticalVector.AngleTo(this.doc.ActiveView.UpDirection) > Math.PI*.5)
					{
						i = 3;
						i2 = 2;
						i3 = 1;
						i4 = 0;
					}
				}
			}
			if (this.frm.chkName.Checked)
			{
				this.CreateNameTag(i);
			}
			this.CreateSizeTag(i3);
			this.CreateQuantityTag(i2);
			if (this.frm.chkAirAmount.Checked)
			{
				this.CreateAirAmountTag(i4);
			}
		}

		private void CreateTags()
		{
			this.independentTags.Clear();
			int i = 0;
			int i2 = 1;
			if (this.tagDirectionVector.VerticalVector.AngleTo(this.doc.ActiveView.UpDirection) > Math.PI*.5)
			{
				i = 1;
				i2 = 0;
			}
			if (!this.frm.chkName.Checked && !this.frm.chkAirAmount.Checked)
			{
				this.CreateSizeTag(i);
				this.CreateQuantityTag(i2);
			}
			if (this.frm.chkName.Checked && !this.frm.chkAirAmount.Checked)
			{
				this.CreateNameAndSizeTag(i);
				this.CreateQuantityTag(i2);
			}
			if (!this.frm.chkName.Checked && this.frm.chkAirAmount.Checked)
			{
				this.CreateSizeAndQuantityTag(i);
				this.CreateAirAmountTag(i2);
			}
			if (this.frm.chkName.Checked && this.frm.chkAirAmount.Checked)
			{
				this.CreateNameAndSizeTag(i);
				this.CreateQuantityAndAirAmountTag(i2);
			}
		}

		private void CreateNameTag(int i)
		{
			FamilySymbol familySymbol = this.GetFamilySymbol("MarkTag", "HY_风口标注.rfa", "风口名称");
			IndependentTag independentTag = RevitVersionFuncs.NewTag(this.doc, this.doc.ActiveView, new Reference(this.elem), false, 0, 0, this.CalculateTagPosition(i));
			independentTag.ChangeTypeId(familySymbol.Id);
			this.independentTags.Add(independentTag);
			AssociationMarkInfo.WriteMarkInfoToElement(independentTag, MarkType.DuctTerminal);
		}

		private void CreateSizeTag(int i)
		{
			FamilySymbol familySymbol = this.GetFamilySymbol("MarkTag", "HY_风口标注.rfa", "风口尺寸");
			IndependentTag independentTag = RevitVersionFuncs.NewTag(this.doc, this.doc.ActiveView, new Reference(this.elem), false, 0, 0, this.CalculateTagPosition(i));
			independentTag.ChangeTypeId(familySymbol.Id);
			this.independentTags.Add(independentTag);
			AssociationMarkInfo.WriteMarkInfoToElement(independentTag, MarkType.DuctTerminal);
		}

		private void CreateQuantityTag(int i)
		{
			FamilySymbol familySymbol = this.GetFamilySymbol("MarkTag", "HY_风口标注.rfa", "风口数量");
			IndependentTag independentTag = RevitVersionFuncs.NewTag(this.doc, this.doc.ActiveView, new Reference(this.elem), false, 0, 0, this.CalculateTagPosition(i));
			independentTag.ChangeTypeId(familySymbol.Id);
			this.independentTags.Add(independentTag);
			AssociationMarkInfo.WriteMarkInfoToElement(independentTag, MarkType.DuctTerminal);
		}

		private void CreateAirAmountTag(int i)
		{
			FamilySymbol familySymbol = this.GetFamilySymbol("MarkTag", "HY_风口标注.rfa", "风口风量");
			IndependentTag independentTag = RevitVersionFuncs.NewTag(this.doc, this.doc.ActiveView, new Reference(this.elem), false, 0, 0, this.CalculateTagPosition(i));
			independentTag.ChangeTypeId(familySymbol.Id);
			this.independentTags.Add(independentTag);
			AssociationMarkInfo.WriteMarkInfoToElement(independentTag, MarkType.DuctTerminal);
		}

		private void CreateNameAndSizeTag(int i)
		{
			FamilySymbol familySymbol = (this.frm.markSetting.Splite == "空格") ? this.GetFamilySymbol("MarkTag", "HY_风口标注_空格.rfa", "风口名称尺寸") : this.GetFamilySymbol("MarkTag", "HY_风口标注.rfa", "风口名称尺寸");
			IndependentTag independentTag = RevitVersionFuncs.NewTag(this.doc, this.doc.ActiveView, new Reference(this.elem), false, 0, 0, this.CalculateTagPosition(i));
			independentTag.ChangeTypeId(familySymbol.Id);
			this.independentTags.Add(independentTag);
			AssociationMarkInfo.WriteMarkInfoToElement(independentTag, MarkType.DuctTerminal);
		}

		private void CreateSizeAndQuantityTag(int i)
		{
			FamilySymbol familySymbol = (this.frm.markSetting.Splite == "空格") ? this.GetFamilySymbol("MarkTag", "HY_风口标注_空格.rfa", "风口尺寸数量") : this.GetFamilySymbol("MarkTag", "HY_风口标注.rfa", "风口尺寸数量");
			IndependentTag independentTag = RevitVersionFuncs.NewTag(this.doc, this.doc.ActiveView, new Reference(this.elem), false, 0, 0, this.CalculateTagPosition(i));
			independentTag.ChangeTypeId(familySymbol.Id);
			this.independentTags.Add(independentTag);
			AssociationMarkInfo.WriteMarkInfoToElement(independentTag, MarkType.DuctTerminal);
		}

		private void CreateQuantityAndAirAmountTag(int i)
		{
			FamilySymbol familySymbol = (this.frm.markSetting.Splite == "空格") ? this.GetFamilySymbol("MarkTag", "HY_风口标注_空格.rfa", "风口数量风量") : this.GetFamilySymbol("MarkTag", "HY_风口标注.rfa", "风口数量风量");
			IndependentTag independentTag = RevitVersionFuncs.NewTag(this.doc, this.doc.ActiveView, new Reference(this.elem), false, 0, 0, this.CalculateTagPosition(i));
			independentTag.ChangeTypeId(familySymbol.Id);
			this.independentTags.Add(independentTag);
			AssociationMarkInfo.WriteMarkInfoToElement(independentTag, MarkType.DuctTerminal);
		}

		private XYZ CalculateTagPosition(int i)
		{
			XYZ result = new XYZ();
			if (this.frm.markSetting.DrawLineBox == "true")
			{
				if (!this.frm.chkName.Checked && !this.frm.chkAirAmount.Checked)
				{
					if (i != 1)
					{
						if (i == 2)
						{
							result = this.tagLocation + this.tagDirectionVector.HorizontalVector * AssistFunc.mmToFeet(this.maxLength / 2.0) * (double)this.doc.ActiveView.Scale / 100.0 + this.tagDirectionVector.VerticalVector * AssistFunc.mmToFeet(this.verticalLineLength / 2.0) * (double)this.doc.ActiveView.Scale / 100.0;
						}
					}
					else
					{
						result = this.tagLocation + this.tagDirectionVector.HorizontalVector * AssistFunc.mmToFeet(this.maxLength / 2.0) * (double)this.doc.ActiveView.Scale / 100.0 + this.tagDirectionVector.VerticalVector * AssistFunc.mmToFeet(this.verticalLineLength * 3.0 / 2.0) * (double)this.doc.ActiveView.Scale / 100.0;
					}
				}
				else
				{
					switch (i)
					{
					case 0:
						result = this.tagLocation + this.tagDirectionVector.HorizontalVector * AssistFunc.mmToFeet(this.maxLength / 2.0) * (double)this.doc.ActiveView.Scale / 100.0 + this.tagDirectionVector.VerticalVector * AssistFunc.mmToFeet(this.verticalLineLength * 3.0 / 2.0) * (double)this.doc.ActiveView.Scale / 100.0;
						break;
					case 1:
						result = this.tagLocation + this.tagDirectionVector.HorizontalVector * AssistFunc.mmToFeet(this.maxLength / 2.0) * (double)this.doc.ActiveView.Scale / 100.0 + this.tagDirectionVector.VerticalVector * AssistFunc.mmToFeet(this.verticalLineLength / 2.0) * (double)this.doc.ActiveView.Scale / 100.0;
						break;
					case 2:
						result = this.tagLocation + this.tagDirectionVector.HorizontalVector * AssistFunc.mmToFeet(this.maxLength / 2.0 + this.maxLength + RevitVersionFuncs.GetLineFrontWidth(true)) * (double)this.doc.ActiveView.Scale / 100.0 + this.tagDirectionVector.VerticalVector * AssistFunc.mmToFeet(this.verticalLineLength * 3.0 / 2.0) * (double)this.doc.ActiveView.Scale / 100.0;
						break;
					case 3:
						result = this.tagLocation + this.tagDirectionVector.HorizontalVector * AssistFunc.mmToFeet(this.maxLength / 2.0 + this.maxLength + RevitVersionFuncs.GetLineFrontWidth(true)) * (double)this.doc.ActiveView.Scale / 100.0 + this.tagDirectionVector.VerticalVector * AssistFunc.mmToFeet(this.verticalLineLength / 2.0) * (double)this.doc.ActiveView.Scale / 100.0;
						break;
					}
				}
			}
			else if (i != 0)
			{
				if (i == 1)
				{
					result = this.tagLocation + this.tagDirectionVector.HorizontalVector * AssistFunc.mmToFeet(this.maxLength / 2.0) * (double)this.doc.ActiveView.Scale / 100.0 - this.tagDirectionVector.VerticalVector * AssistFunc.mmToFeet(this.fontHigtht * 200.0 + this.leadDistance) * (double)this.doc.ActiveView.Scale / 100.0;
				}
			}
			else
			{
				result = this.tagLocation + this.tagDirectionVector.HorizontalVector * AssistFunc.mmToFeet(this.maxLength / 2.0) * (double)this.doc.ActiveView.Scale / 100.0 + this.tagDirectionVector.VerticalVector * AssistFunc.mmToFeet(this.fontHigtht * 200.0 + this.leadDistance) * (double)this.doc.ActiveView.Scale / 100.0;
			}
			return result;
		}

		private void SetTagLinesLength()
		{
			this.CreateIndependentTags();
			List<int> list = new List<int>();
			int num = 10;
			foreach (IndependentTag independentTag in this.independentTags)
			{
				if (num < StringTools.GetStringByteLength(independentTag.TagText))
				{
					num = StringTools.GetStringByteLength(independentTag.TagText);
				}
				list.Add(independentTag.Id.IntegerValue);
			}
			MarkDuctTerminalUtility.tagBytes = num;
			MarkDuctTerminalUtility.leadDistance = 0.0;
			this.maxLength = (double)(num * 160) * this.fontHigtht * this.fontWidth * this.frm.commFont.LeadRotia;
			this.independentTags.Clear();
			foreach (int num2 in list)
			{
				this.doc.DeleteElement(this.doc.GetElement(new ElementId(num2)));
			}
		}

		private void SetTagParams()
		{
			this.newgrpElements.Clear();
			if (this.frm.commFont.FontHeight > 0.0 && this.frm.commFont.FontGWRotia > 0.0)
			{
				this.fontHigtht = this.frm.commFont.FontHeight / 3.0;
				this.fontWidth = this.frm.commFont.FontGWRotia;
			}
			this.leadDistance = this.frm.commFont.LeadDistance;
			MarkDuctTerminalUtility.fontHigtht = this.fontHigtht;
			MarkDuctTerminalUtility.fontWidth = this.fontWidth * this.frm.commFont.LeadRotia;
			MarkDuctTerminalUtility.leadDistance = this.leadDistance;
			using (SubTransaction subTransaction = new SubTransaction(this.doc))
			{
				subTransaction.Start();
				this.elem.GetParameter("风口名称").Set(this.elem.GetParameter((BuiltInParameter)(-1002051)).AsValueString());
				if (this.frm.markSetting.Splite.Contains("空格"))
				{
					this.elem.GetParameter("分隔符").Set(" ");
				}
				else
				{
					this.elem.GetParameter("分隔符").Set(this.frm.markSetting.Splite);
				}
				this.elem.GetParameter("风口数量").Set(this.elems.Count.ToString() + "个");
				subTransaction.Commit();
			}
		}

		private FamilySymbol GetFamilySymbol(string typeName, string familyName, string familySymbolName)
		{
			FamilySymbol result = null;
			string text = Path.Combine(Product.FamilyLocation, RevitVersion.GetVersionNumber(this.doc), typeName, familyName);
			Family family = null;
			SubTransaction subTransaction = null;
			try
			{
				foreach (Element element in YJKElementFilter.GetElementByCategory(this.doc, typeof(FamilySymbol), BuiltInCategory.OST_DuctTerminalTags))
				{
					if ((element as FamilySymbol).Family.Name == familyName.Substring(0, familyName.IndexOf(".")) && element.Name == familySymbolName)
					{
						FamilySymbol result2;
						result = (result2 = (element as FamilySymbol));
						return result2;
					}
				}
				subTransaction = new SubTransaction(this.doc);
				subTransaction.Start();
				this.doc.LoadFamily(text, out family);
				subTransaction.Commit();
			}
			catch (Exception)
			{
			}
			finally
			{
				if (subTransaction != null && (int)subTransaction.GetStatus() != 3)
				{
					subTransaction.RollBack();
				}
			}
			if (family != null)
			{
				foreach (FamilySymbol familySymbol in family.GetSymbols())
				{
					if (familySymbol.Name == familySymbolName)
					{
						result = familySymbol;
						break;
					}
				}
			}
			return result;
		}

		private void LoadFamily()
		{
			this.fs = this.GetFamilySymbol("MarkTag", "HY_风口标注.rfa", "风口名称");
			this.fsSpace = this.GetFamilySymbol("MarkTag", "HY_风口标注_空格.rfa", "风口名称尺寸");
		}

		private void SetFamilyParams()
		{
			MarkOperation markOperation = new MarkOperation();
			CommonFont commonFont = new CommonFont
			{
				Font = this.frm.commFont.Font,
				FontHeight = this.frm.commFont.FontHeight,
				Align = this.frm.commFont.Align,
				FontGWRotia = this.frm.commFont.FontGWRotia,
				LeadDistance = this.frm.commFont.LeadDistance,
				LeadRotia = this.frm.commFont.LeadRotia,
				Presice = this.frm.commFont.Presice,
				TubeDistance = this.frm.commFont.TubeDistance
			};
			markOperation.EditHYFamilyFont(this.fs.Family, commonFont, false);
			markOperation.EditHYFamilyFont(this.fsSpace.Family, commonFont, false);
		}

		private List<Element> GetPreSelectedElems(List<ElementId> selectedElemIds)
		{
			List<Element> list = new List<Element>();
			foreach (ElementId elementId in selectedElemIds)
			{
				Element element = this.doc.GetElement(elementId);
				if (element.Category.Id.IntegerValue == -2008013)
				{
					list.Add(element);
				}
			}
			return list;
		}

		private UIDocument uiDoc;

		private Document doc;

		private FrmDuctTerminalTag frm;

		private List<Element> elems = new List<Element>();

		private Element elem;

		private XYZ tagLocation = new XYZ();

		private DirectionVector tagDirectionVector = new DirectionVector();

		private List<Line> tagLines = new List<Line>();

		public ElementSet newgrpElements = new ElementSet();

		private List<IndependentTag> independentTags = new List<IndependentTag>();

		private double maxLength;

		private double fontHigtht = 1.0;

		private double fontWidth = 1.0;

		private double leadDistance;

		private double verticalLineLength;

		private Transaction transaction;

		private FamilySymbol fs;

		private FamilySymbol fsSpace;

		private YJKLine singleLine;
	}
}
